//
//  ViewController.m
//  MyTest
//
//  Created by rayootech on 15/9/26.
//  Copyright (c) 2015年 rayootech. All rights reserved.
//

#import "ZWMainViewController.h"
#import "ZWDrawViewController.h"
#import "ZWClipViewController.h"
#import "ZWTuYaViewController.h"
@interface ZWMainViewController ()<UITableViewDataSource,UITableViewDelegate>
{
    UITableView *zwmainTableview;
    
}
@property(nonatomic,copy)NSArray *titlesArray;
@property(nonatomic,copy)NSArray *controllersArray;
@end

static NSString *tbID=@"zwTbCell";
@implementation ZWMainViewController

//标题数组
-(NSArray *)titlesArray{

    if (!_titlesArray) {
        _titlesArray=[NSArray arrayWithObjects:@"画Cell",@"屏幕截图",@"涂鸦", nil];
    }
    
    return _titlesArray;
}

//标题数组
-(NSArray *)controllersArray{
    
    if (!_controllersArray) {
        //造控制器
        ZWDrawViewController *drawVC=[[ZWDrawViewController alloc]init];
        ZWClipViewController *clipVC=[[ZWClipViewController alloc]init];
        ZWTuYaViewController *tuyaVC=[[ZWTuYaViewController alloc]init];
        _controllersArray=[NSArray arrayWithObjects:drawVC,clipVC,tuyaVC, nil];
    }
    
    return _controllersArray;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title=@"主界面";
    //创建列表

    UITableView *maintableView=[[UITableView alloc]initWithFrame:self.view.bounds];
    maintableView.delegate=self;
    maintableView.dataSource=self;
    [self.view addSubview:maintableView];
    zwmainTableview=maintableView;
    
}


#pragma mark-zwmainTableview代理方法
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

    return self.titlesArray.count;
    
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
   
    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:tbID];
    if (cell==nil) {
        cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:tbID];
        cell.textLabel.text=self.titlesArray[indexPath.row];
        UIImage *arrowimg=[UIImage imageNamed:@"Arrow"];
        UIImageView *arrowimgView=[[UIImageView alloc]initWithFrame:CGRectMake(self.view.bounds.size.width-25-5, 15, 15, 15)];
        arrowimgView.image=arrowimg;
        [cell.contentView addSubview:arrowimgView];
    }
    cell.selectionStyle=UITableViewCellSelectionStyleNone;
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

    return 40;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    UIViewController *viewVC=self.controllersArray[indexPath.row];
    [self.navigationController pushViewController:viewVC animated:YES];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
